"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));

var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));

var _jsxRuntime = require("react/jsx-runtime");

var _icons = require("@ant-design/icons");

var _antdV = require("antd-v4");

var _classnames = _interopRequireDefault(require("classnames"));

var _react = require("react");

require("./index.less");

var _excluded = ["className", "layout", "style", "description", "children", "title", "tip", "status", "trend", "prefix", "icon"];

var Statistic = function Statistic(props) {
  var _classNames;

  var className = props.className,
      _props$layout = props.layout,
      layout = _props$layout === void 0 ? 'inline' : _props$layout,
      _props$style = props.style,
      style = _props$style === void 0 ? {} : _props$style,
      description = props.description,
      children = props.children,
      title = props.title,
      tip = props.tip,
      status = props.status,
      trend = props.trend,
      prefix = props.prefix,
      icon = props.icon,
      others = (0, _objectWithoutProperties2.default)(props, _excluded);

  var _useContext = (0, _react.useContext)(_antdV.ConfigProvider.ConfigContext),
      getPrefixCls = _useContext.getPrefixCls;

  var prefixCls = getPrefixCls('pro-card-statistic');
  var classString = (0, _classnames.default)(prefixCls, className);
  var statusClass = (0, _classnames.default)("".concat(prefixCls, "-status"));
  var iconClass = (0, _classnames.default)("".concat(prefixCls, "-icon"));
  var wrapperClass = (0, _classnames.default)("".concat(prefixCls, "-wrapper"));
  var contentClass = (0, _classnames.default)("".concat(prefixCls, "-content"));
  var statisticClassName = (0, _classnames.default)((_classNames = {}, (0, _defineProperty2.default)(_classNames, "".concat(prefixCls, "-layout-").concat(layout), layout), (0, _defineProperty2.default)(_classNames, "".concat(prefixCls, "-trend-").concat(trend), trend), _classNames));
  var tipDom = tip && (0, _jsxRuntime.jsx)(_antdV.Tooltip, {
    title: tip,
    children: (0, _jsxRuntime.jsx)(_icons.QuestionCircleOutlined, {
      className: "".concat(prefixCls, "-tip")
    })
  });
  var trendIconClassName = (0, _classnames.default)("".concat(prefixCls, "-trend-icon"), (0, _defineProperty2.default)({}, "".concat(prefixCls, "-trend-icon-").concat(trend), trend));
  var trendDom = trend && (0, _jsxRuntime.jsx)("div", {
    className: trendIconClassName
  });
  var statusDom = status && (0, _jsxRuntime.jsx)("div", {
    className: statusClass,
    children: (0, _jsxRuntime.jsx)(_antdV.Badge, {
      status: status,
      text: null
    })
  });
  var iconDom = icon && (0, _jsxRuntime.jsx)("div", {
    className: iconClass,
    children: icon
  });
  return (0, _jsxRuntime.jsxs)("div", {
    className: classString,
    style: style,
    children: [iconDom, (0, _jsxRuntime.jsxs)("div", {
      className: wrapperClass,
      children: [statusDom, (0, _jsxRuntime.jsxs)("div", {
        className: contentClass,
        children: [(0, _jsxRuntime.jsx)(_antdV.Statistic, (0, _objectSpread2.default)({
          title: (title || tipDom) && (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
            children: [title, tipDom]
          }),
          prefix: (trendDom || prefix) && (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
            children: [trendDom, prefix]
          }),
          className: statisticClassName
        }, others)), description && (0, _jsxRuntime.jsx)("div", {
          className: "".concat(prefixCls, "-description"),
          children: description
        })]
      })]
    })]
  });
};

var _default = Statistic;
exports.default = _default;